Skip to content

feat: Show sections/subsections/units available for sync in library sync page [FC-0097] #2271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Aug 14, 2025

Conversation

ChrisChV
Copy link
Contributor

@ChrisChV ChrisChV commented Jul 13, 2025

Description

  • Adds Units, Subsection, and section cards in the libraries sync page.
  • Rename of mockGetEntityLinks to mockGetComponentEntityLinks
  • Use the top-level parent logic
  • Which user roles will this change impact? "Course Author".
image

Supporting information

Testing instructions

Check summary of libraries

  • Create a new library and a new course.
  • In the library, create a unit and a component. Publish the library.
  • Go to the course and add a unit from the library. Also, add the component from the library.
  • Go to Content > Library Updates.
  • On the Libraries Tab, verify that you see the library and 2 component applied.

TODO: It's missing some changes in the counts of the summary (see #2168 (comment))

Check out of sync list with top-level parent logic

  • Create a new library and a new course.
  • In the library, you need to create this nested structure: Section > Subsection > Unit > Component.
  • Publish the library.
  • In the course:
    • Import the Section from the library.
    • Create a simple Section. In this section:
      • Import the Subsection from the library.
      • Create a simple Subsection. In this subsection:
        • Import the Unit from the library.
        • Create a simple Unit. In this unit:
          • Import the Component from the library.
  • Go to Content > Library Updates.
  • Verify the summary.
  • Go to the library, update the Section name, and publish it.
  • Go to Content > Library Updates. Verify that you only see the Section card to update. Click on Update
  • Go to the library, update the Subsection name, and publish it.
  • Go to Content > Library Updates. Verify that you can see:
    • The Section card; that is the top-level parent of the subsection.
    • The Subsection card; that was imported on its own.
  • Update all.
  • Go to the library, update the Unit name, and publish it.
  • Go to Content > Library Updates. Verify that you can see:
    • The Section card; that is the top-level parent when importing the section.
    • The Subsection card; that is the top-level parent when importing the subsection.
    • The Unit card; that was imported on its own.
  • Update all.
  • Go to the library, update the Component name, and publish it.
  • Go to Content > Library Updates. Verify that you can see:
    • The Section card; that is the top-level parent when importing the section.
    • The Subsection card; that is the top-level parent when importing the subsection.
    • The Unit card; that is the top-level parent when importing the unit.
    • The Component card, which was imported on its own.

Note: This is the most basic way to test top-level parent logic; there are many more possibilities. I invite you to try several paths and possibilities.

Other information

TODO:

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Deprecated propTypes, defaultProps, and injectIntl patterns are not used in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Imports avoid using ../. To import from parent folders, use @src, e.g. import { initializeMocks } from '@src/testUtils'; instead of from '../../../../testUtils'

@openedx-webhooks
Copy link

openedx-webhooks commented Jul 13, 2025

Thanks for the pull request, @ChrisChV!

This repository is currently maintained by @bradenmacdonald.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 13, 2025
@ChrisChV ChrisChV marked this pull request as draft July 13, 2025 00:05
@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Jul 13, 2025
Copy link

codecov bot commented Jul 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.47%. Comparing base (74e671d) to head (304191e).
⚠️ Report is 25 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2271      +/-   ##
==========================================
+ Coverage   94.41%   94.47%   +0.06%     
==========================================
  Files        1167     1169       +2     
  Lines       24928    25136     +208     
  Branches     5416     5494      +78     
==========================================
+ Hits        23535    23748     +213     
+ Misses       1326     1317       -9     
- Partials       67       71       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ChrisChV ChrisChV changed the title refactor: Rename mockGetEntityLinks to mockGetComponentEntityLinks refactor: Rename mockGetEntityLinks to mockGetComponentEntityLinks [FC-0097] Jul 15, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Jul 15, 2025
@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Jul 15, 2025
@ChrisChV ChrisChV changed the title refactor: Rename mockGetEntityLinks to mockGetComponentEntityLinks [FC-0097] feat: Show sections/subsections/units available for sync in library sync page [FC-0097] Jul 18, 2025
@ChrisChV
Copy link
Contributor Author

@navinkarkera

- Go to Content > Library Updates. Verify that you can see:
   - The Section card; that is the top-level parent when importing the section.
   - The Subsection card; that is the top-level parent when importing the subsection.
   - The Unit card; that was imported on its own.
- Update all.

On this step, I got this error after updating the Section. Could you verify if you get the same?

cms-1               | Traceback (most recent call last):
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/redis/connection.py", line 385, in connect_check_health
cms-1               |     sock = self.retry.call_with_retry(
cms-1               |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/redis/retry.py", line 87, in call_with_retry
cms-1               |     return do()
cms-1               |            ^^^^
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/redis/connection.py", line 386, in <lambda>
cms-1               |     lambda: self._connect(), lambda error: self.disconnect(error)
cms-1               |             ^^^^^^^^^^^^^^^
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/redis/connection.py", line 761, in _connect
cms-1               |     for res in socket.getaddrinfo(
cms-1               |                ^^^^^^^^^^^^^^^^^^^
cms-1               |   File "/opt/pyenv/versions/3.11.8/lib/python3.11/socket.py", line 962, in getaddrinfo
cms-1               |     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
cms-1               |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1               | socket.gaierror: [Errno -2] Name or service not known
cms-1               | 
cms-1               | During handling of the above exception, another exception occurred:
cms-1               | 
cms-1               | Traceback (most recent call last):
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/edx_event_bus_redis/internal/producer.py", line 136, in send
cms-1               |     msg_id = stream.add(stream_data, maxlen=STREAM_MAX_LEN, approximate=True)
cms-1               |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/walrus/containers.py", line 1071, in add
cms-1               |     return self.database.xadd(self.key, data, id, maxlen, approximate)
cms-1               |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/redis/commands/core.py", line 3538, in xadd
cms-1               |     return self.execute_command("XADD", name, *pieces)
cms-1               |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/redis/client.py", line 623, in execute_command
cms-1               |     return self._execute_command(*args, **options)
cms-1               |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/redis/client.py", line 629, in _execute_command
cms-1               |     conn = self.connection or pool.get_connection()
cms-1               |                               ^^^^^^^^^^^^^^^^^^^^^
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/redis/utils.py", line 191, in wrapper
cms-1               |     return func(*args, **kwargs)
cms-1               |            ^^^^^^^^^^^^^^^^^^^^^
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/redis/connection.py", line 1530, in get_connection
cms-1               |     connection.connect()
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/redis/connection.py", line 379, in connect
cms-1               |     self.connect_check_health(check_health=True)
cms-1               |   File "/openedx/venv/lib/python3.11/site-packages/redis/connection.py", line 391, in connect_check_health
cms-1               |     raise ConnectionError(self._error_message(e))
cms-1               | redis.exceptions.ConnectionError: Error -2 connecting to edx.devstack.redis:6379. Name or service not known.
cms-1               | 
cms-1               | During handling of the above exception, another exception occurred:

@ChrisChV ChrisChV requested a review from navinkarkera July 28, 2025 21:13
Copy link
Contributor

@navinkarkera navinkarkera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChrisChV Nice work! 👍

  • I tested this: (Tested links with different components and containers in courses)
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

@navinkarkera
Copy link
Contributor

On this step, I got this error after updating the Section. Could you verify if you get the same?

@ChrisChV This is due to incorrect (legacy url) EVENT_BUS_REDIS_CONNECTION_URL in edx-platform but should not have any effect here.

@ChrisChV
Copy link
Contributor Author

ChrisChV commented Jul 29, 2025

On this step, I got this error after updating the Section. Could you verify if you get the same?

@ChrisChV This is due to incorrect (legacy url) EVENT_BUS_REDIS_CONNECTION_URL in edx-platform but should not have any effect here.

@navinkarkera Thanks! One more question, in this case (publish the Unit), can you update the section in the course successfully? In my case, it is not like that; suddenly, it is the configuration of my instance

- Go to the library, update the Unit name, and publish it.
- Go to Content > Library Updates. Verify that you can see:
   - The Section card; that is the top-level parent when importing the section.
   - The Subsection card; that is the top-level parent when importing the subsection.
   - The Unit card; that was imported on its own.
- Update all.

@navinkarkera
Copy link
Contributor

@ChrisChV Hmm, I had some weird issues yesterday while updating sections which I could not reproduce but today I was able to do it. Even after updating a section, it doesn't go away from the links page. I see below response from the API

[
    {
        "id": 249,
        "upstream_context_title": "CS3",
        "upstream_version": 5,
        "ready_to_sync": false,
        "upstream_context_key": "lib:UNIX:UXLIB1",
        "downstream_usage_key": "block-v1:UNIX+UX3+2025_T3+type@chapter+block@ab1c996f938f4de4b5f255f4d0672737",
        "downstream_context_key": "course-v1:UNIX+UX3+2025_T3",
        "top_level_parent_usage_key": null,
        "version_synced": 5,
        "version_declined": null,
        "created": "2025-07-29T12:28:57.823885Z",
        "updated": "2025-07-29T12:42:28.704113Z",
        "upstream_key": "lct:UNIX:UXLIB1:section:1-section-from-lib-154bc8",
        "upstream_type": "container"
    }
]

ready_to_sync is false even when the upstream_version and version_synced are same. The summary API also returns incorrect results due to this.

@ChrisChV
Copy link
Contributor Author

@ChrisChV Hmm, I had some weird issues yesterday while updating sections which I could not reproduce but today I was able to do it. Even after updating a section, it doesn't go away from the links page. I see below response from the API

[
    {
        "id": 249,
        "upstream_context_title": "CS3",
        "upstream_version": 5,
        "ready_to_sync": false,
        "upstream_context_key": "lib:UNIX:UXLIB1",
        "downstream_usage_key": "block-v1:UNIX+UX3+2025_T3+type@chapter+block@ab1c996f938f4de4b5f255f4d0672737",
        "downstream_context_key": "course-v1:UNIX+UX3+2025_T3",
        "top_level_parent_usage_key": null,
        "version_synced": 5,
        "version_declined": null,
        "created": "2025-07-29T12:28:57.823885Z",
        "updated": "2025-07-29T12:42:28.704113Z",
        "upstream_key": "lct:UNIX:UXLIB1:section:1-section-from-lib-154bc8",
        "upstream_type": "container"
    }
]

ready_to_sync is false even when the upstream_version and version_synced are same. The summary API also returns incorrect results due to this.

@navinkarkera Thanks! I found the issue. I fixed it in openedx/edx-platform@34cd5a4 and openedx/edx-platform@2964783

@ChrisChV
Copy link
Contributor Author

The summary API also returns incorrect results due to this.

@navinkarkera Yes, I have a Product question about this: #2168 (comment)

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me.

@ChrisChV ChrisChV merged commit 25830a2 into openedx:master Aug 14, 2025
7 checks passed
@github-project-automation github-project-automation bot moved this from Waiting on Author to Done in Contributions Aug 14, 2025
@ChrisChV ChrisChV deleted the chris/FAL-4230-entity-links-update branch August 14, 2025 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants